package com.eastfair.pay.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 调用银联日志
 * </p>
 *
 * @author linan
 * @date 2023-06-01
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ChinaumsLogRequestTypeEnum", description = "请求类型 #{PAY:下单支付;QUERY:查询;REFUND:退款-枚举")
public enum ChinaumsLogRequestTypeEnum implements BaseEnum {

    /**
     * PAY="下单支付"
     */
    PAY("下单支付"),
    /**
     * QUERY="查询"
     */
    QUERY("查询"),
    /**
     * REFUND="退款"
     */
    REFUND("退款"),
    /**
     * REFUND_QUERY="退款查询"
     */
    REFUND_QUERY("退款查询"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ChinaumsLogRequestTypeEnum match(String val, ChinaumsLogRequestTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ChinaumsLogRequestTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ChinaumsLogRequestTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "PAY,QUERY,REFUND,REFUND_QUERY", example = "PAY")
    public String getCode() {
        return this.name();
    }

}
